package com.shuangti.webdemo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shuangti.webdemo.dto.PageDTO;
import com.shuangti.webdemo.po.Emp;
import com.shuangti.webdemo.query.EmpPage;
import com.shuangti.webdemo.query.PageQuery;
import com.shuangti.webdemo.vo.EmpPageVo;
import com.shuangti.webdemo.po.Result;
import com.shuangti.webdemo.servvice.EmpService;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/emps")
@RequiredArgsConstructor
public class EmpController {

    private final EmpService empService;
    /**
     * 简单分页查询员工信息
     */
        @GetMapping("/list")
       Result getEmp(){

            Page<Emp> list = empService.getList();

            return Result.success(list);
    }
    /**
     * 复杂分页查询员工信息
     */
//    @GetMapping("/pages")
//    public Result selectEmpList(EmpPage pages){
//
//
//           return Result.success(empService.pageList(pages));
//    }
    /**
     * 根据员工id批量删除员工信息
     */
    @DeleteMapping()
    public Result deleteList(@RequestParam List<Integer> ids){

        empService.deleteByIds(ids);
        return Result.success();

    }

    /**
     * 根据员工id查询回显信息
     *
     */
    @GetMapping("/{id}")
    public Result getByid(@PathVariable Integer id){

        Emp emp = empService.selectByid(id);

        return Result.success(emp);
    }
}
